#include "widget.h"
#include "ui_widget.h"
#include "connectionpool.h"
#include "mytask.h"
#include <QPushButton>
#include <QSqlDatabase>
#include <QSqlError>
#include <qthreadpool.h>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    qDebug()<<QSqlDatabase::drivers();
    qDebug()<<QThread::currentThread();

    QPushButton *btn = new QPushButton(this);
    btn->setText("获取连接");

    //ConnectionPool *pool = ConnectionPool::getConnectionPool();
    //pool->closeConnection(conn6);
    //qDebug()<<conn;
    //pool->recycleConnection(conn);// 回收

    MyTask *mt = new MyTask;
    QThreadPool *thp =QThreadPool::globalInstance();

    connect(btn,&QPushButton::clicked,this,[=](){
        thp->start(mt);
    });

}

Widget::~Widget()
{
    delete ui;
}


